<?php

class Skjb_Validate_ForEach extends Zend_Validate_Abstract
{
    private $_validator = null;
    
    public function __construct(Zend_Validate $validator)
    {
        $this->_validator = $validator;
    }
    
    public function isValid($values)
    {
        $valid = true;
        
        foreach ($values as $value) {
            if (!$this->_validator->isValid($value)) {
                $this->_messages = array_merge($this->_messages, $this->_validator->getMessages());
                $this->_errors = array_merge($this->_errors, $this->_validator->getErrors());
                $valid = false;
            }
        }

        return $valid;
    }
}
